package com.hk.dao;

import com.hk.entity.Stu;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StuDao {

    /**
     * 新增学生
     * @param stu
     */
    void insert(Stu stu);

    /**
     * 查询所有学生信息
     * @return
     */
    List<Stu> queryAll();

    /**
     * 条件查询学生
     * @param stu
     * @return
     */
    List<Stu> serachStu(Stu stu);
    /***
     * 批量删除学生(1, 2, 3)
     * @param ids
     */
    void delete(@Param("ids") List<Integer> ids);

    /**
     * 根据ID查询学生，查询回显
     * @param id
     * @return
     */
    @Select("select stu_id,name,gender,faculty,major,classes,e_mail,phone from stu where id = #{id}")
    Stu getById(Integer id);

    /**
     * 更新学生信息
     * @param stu
     */
    void update(@Param("stu") Stu stu);

    @Select("SELECT * FROM stu WHERE stu_id = #{stuId} AND password = #{password}")
    Stu findByStuIdAndPassword(@Param("stuId") String stuId, @Param("password") String password);

    @Insert("INSERT INTO stu (stu_id, name, gender, faculty, major, classes, e_mail, phone, password) " +
            "VALUES (#{stuId}, #{name}, #{gender}, #{faculty}, #{major}, #{classes}, #{eMail}, #{phone}, #{password})")
    int inserts(Stu stu);

    @Select("SELECT * FROM stu WHERE stu_id = #{stuId}")
    Stu findByStuId(String stuId);
    @Select("SELECT stu_id,name,gender,faculty,phone,e_mail,image FROM stu WHERE stu_id = #{stuId}")
    Stu HomeInfo(String stuId);

    void uploadStu(@Param("url") String url, @Param("stuId") String stuId);
}
